next up previous
Next: References Up: Programming X Overlay Windows Previous: C layerdemo.c

D xlayerinfo.c

/* compile: cc -o xlayerinfo xlayerinfo.c XLayerUtil.c -lX11 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "XLayerUtil.h"

void
main(argc, argv)
int argc;
char *argv[];
{
   Display *dpy;
   char *display_name, *arg, *class;
   XLayerVisualInfo template, *lvinfo;
   int nVisuals, i;

   display_name = NULL;
   for(i=1; i<argc; i++) {
      arg = argv[i];
      if(strcmp(arg, "-display") == 0 || strcmp(arg, "-d") == 0) {
         if(++i >= argc) {
            fprintf(stderr, "nmbxdemo: missing argument to -display\n");
            exit(1);
         }
         display_name = argv[i];
      }
   }
   dpy = XOpenDisplay(display_name);
   if(dpy == NULL) {
      fprintf(stderr, "xlayerinfo: cannot open display %s\n",
         XDisplayName(NULL));
      exit(1);
   }
   lvinfo = XGetLayerVisualInfo(dpy, 0L, &template, &nVisuals);
   for(i=0; i<nVisuals; i++) {
      printf("  Visual ID: 0x%x\n", lvinfo[i].vinfo.visualid);
      printf("    screen: %d\n", lvinfo[i].vinfo.screen);
      printf("    depth: %d\n", lvinfo[i].vinfo.depth);
      switch(lvinfo[i].vinfo.class) {
         case StaticGray:   class = "StaticGray"; break;
         case GrayScale:    class = "GrayScale"; break;
         case StaticColor:  class = "StaticColor"; break;
         case PseudoColor:  class = "PseudoColor"; break;
         case TrueColor:    class = "TrueColor"; break;
         case DirectColor:  class = "DirectColor"; break;
         default:           class = "Unknown"; break;
      }
      printf("    class: %s\n", class);
      switch(lvinfo[i].type) {
      case None:
         printf("    transparent type: None\n");
         break;
      case TransparentPixel:
         printf("    transparent type: TransparentPixel\n");
         printf("    pixel value: %d\n", lvinfo[i].value);
         break;
      case TransparentMask:
         printf("    transparent type: TransparentMask\n");
         printf("    transparency mask: %0x%x\n", lvinfo[i].value);
         break;
      default:
         printf("    transparent type: Unkown or invalid\n");
         break;
      }
      printf("    layer: %d\n", lvinfo[i].layer);
   }
}



next up previous
Next: References Up: Programming X Overlay Windows Previous: C layerdemo.c



Mark Kilgard
Sun Jan 7 19:28:30 PST 1996